home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 8
/
Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso
/
Aminet
/
comm
/
tcp
/
netinput37_3.lha
/
NetInput
/
source
/
unixsem.doc
< prev
next >
Wrap
Text File
|
1995-07-14
|
4KB
|
128 lines
TABLE OF CONTENTS
sinit
sset
ssignal
swait
sinit sinit
NAME
sinit - Initialize a semaphore for use.
SYNOPSIS
#include <unixsem.h>
extern void sinit
(
CountSemaphore *sem,
ULONG sigmask
);
INPUTS
CountSemaphore *sem
Pointer to a semaphore.
ULONG sigmask
Exec signal-mask to be used for waiting
operations or -1 to used UNIXSEM_SIGMASK.
FUNCTION
This sets various private fields.
The user may provide an Exec style signal-mask which should be used
for waiting operertions concerning THIS semaphore. If signal is
equal to -1, the default signal-mask UNIXSEM_SIGMASK is used. This
is defined in "unixsem.h" And may be altered with succeeding recompilation
of ALL modules using the semaphore calls.
The unit counter is set to zero.
SEE ALSO
sset(), ssignal(), swait()
sset sset
NAME
sset - Set a semaphore to a certain value.
SYNOPSIS
#include <unixsem.h>
extern void sset
(
CountSemaphore *sem,
LONG val
);
INPUTS
CountSemaphore *sem
Pointer to a semaphore.
LONG val
Value the semaphore should be assigned.
FUNCTION
This is done independent of
any task possibly waiting fo the semaphore. Therefore this function
should only be called prior to any call of ssignal() or swait().
To create a mutual exclusion semaphore for protected areas of code,
te following sequence is appropriate:
Sinit(&mutex,-1);
sset(&mutex,1);
Anybody who wants to enter the protected area later should
perform these steps:
Swait(&mutex);
protected area here
ssignal(&mutex);
This has, of course, the same result as an according ObainSemaphore()/
ReleaseSemaphore() construct, but might be useful when porting UNIX
applications.
SEE ALSO
sinit(), ssignal(), swait()
ssignal ssignal
NAME
ssignal - Increment the unit counter of a semaphore.
SYNOPSIS
#include <unixsem.h>
extern void ssignal(CountSemaphore *sem);
INPUTS
CountSemaphore *sem
Pointer to a semaphore.
FUNCTION
If there are any tasks waiting
for a unit, the chronologically first waiter will be awakened.
SEE ALSO
sinit(), sset(), swait()
swait swait
NAME
swait - Decrement the unit count of a semaphore.
SYNOPSIS
#include <unixsem.h>
extern void swait(CountSemaphore *sem);
INPUTS
CountSemaphore *sem
Pointer to a semaphore.
FUNCTION
If the unit count before the
call to swait() was less or equal to zero, the task will be added
to the semaphore's waiting space and fall asleep until sombody
calls ssignal() to the semaphore. If there are already other tasks
within the waiting space, these will be waked up first, before your
task is.
SEE ALSO
sinit(), sset(), ssignal()